package com.example.seataat.storage.controller;

import com.example.seataat.storage.service.StorageService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.alibaba.nacos.client.utils.EnvUtil.LOGGER;

/**
 * @author 季舟
 * @Date 2024-09-14 15:30
 */
@RestController
public class StockController {
    @Resource
    private StorageService storageService;

    @RequestMapping(value = "/deduct", method = RequestMethod.GET, produces = "application/json")
    public String deduct(String commodityCode, int count) {
        try {
            storageService.deduct(commodityCode, count);
        } catch (Exception ex) {
            LOGGER.error("deduct err,", ex);
            throw ex;
        }
        return "SUCCESS";
    }
}
